package com.mx.recycle_adapt.adapt

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
import com.mx.adapt.MXBaseSimpleAdapt
import com.mx.recycle_adapt.databinding.AdaptSimpleImgBinding

class RoundSimpleImgAdapt(list: ArrayList<Int>) : MXBaseSimpleAdapt<Int>(list) {
    override fun getItemCount(): Int {
        return if (list.isNotEmpty()) Int.MAX_VALUE else list.size
    }

    override fun getItem(position: Int): Int? {
        return list.getOrNull(position % list.size)
    }

    override fun createItem(
        inflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): ViewBinding {
        return AdaptSimpleImgBinding.inflate(inflater, parent, false)
    }

    override fun bindView(position: Int, binding: ViewBinding, record: Int) {
        binding as AdaptSimpleImgBinding
        binding.image.setImageResource(record)
    }


}